<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta name="referrer" content="no-referrer"><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>12.Python综合案例-地图可视化 | 王扣笔记</title><meta name="author" content="王扣"><meta name="copyright" content="王扣"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Python入门课程  Python基础综合案例 数据可视化 - 地图可视化 章节目录 [!WARNING|label:本章需要学习的内容]   基础地图使用 疫情地图-国内疫情地图 疫情地图-省级疫情地图  基础地图使用 1. 掌握使用pyecharts构建基础的全国地图可视化图表    代码演示  123456789101112131415161718192021222324252627282">
<meta property="og:type" content="article">
<meta property="og:title" content="12.Python综合案例-地图可视化">
<meta property="og:url" content="http://grace.666443.xyz/posts/e46ce5f3.html">
<meta property="og:site_name" content="王扣笔记">
<meta property="og:description" content="Python入门课程  Python基础综合案例 数据可视化 - 地图可视化 章节目录 [!WARNING|label:本章需要学习的内容]   基础地图使用 疫情地图-国内疫情地图 疫情地图-省级疫情地图  基础地图使用 1. 掌握使用pyecharts构建基础的全国地图可视化图表    代码演示  123456789101112131415161718192021222324252627282">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://p.ananas.chaoxing.com/star3/origin/05fcdda2bab7b7f1768a65f0c49762f8.png">
<meta property="article:published_time" content="2022-12-08T12:02:17.000Z">
<meta property="article:modified_time" content="2022-12-08T12:08:41.970Z">
<meta property="article:author" content="王扣">
<meta property="article:tag" content="笔记 开发">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://p.ananas.chaoxing.com/star3/origin/05fcdda2bab7b7f1768a65f0c49762f8.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://grace.666443.xyz/posts/e46ce5f3"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '12.Python综合案例-地图可视化',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-12-08 20:08:41'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://p.ananas.chaoxing.com/star3/origin/05fcdda2bab7b7f1768a65f0c49762f8.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">王扣笔记</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/photos/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">12.Python综合案例-地图可视化</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-12-08T12:02:17.000Z" title="发表于 2022-12-08 20:02:17">2022-12-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-12-08T12:08:41.970Z" title="更新于 2022-12-08 20:08:41">2022-12-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/python%E5%9F%BA%E7%A1%80/">python基础</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="12.Python综合案例-地图可视化"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Python入门课程-Python基础综合案例-数据可视化-地图可视化"><a href="#Python入门课程-Python基础综合案例-数据可视化-地图可视化" class="headerlink" title="Python入门课程  Python基础综合案例 数据可视化 - 地图可视化"></a>Python入门课程  Python基础综合案例 数据可视化 - 地图可视化</h1><hr>
<h2 id="章节目录"><a href="#章节目录" class="headerlink" title="章节目录"></a><strong>章节目录</strong></h2><blockquote>
<p>[!WARNING|label:本章需要学习的内容]</p>
</blockquote>
<ul>
<li>基础地图使用</li>
<li>疫情地图-国内疫情地图</li>
<li>疫情地图-省级疫情地图</li>
</ul>
<h2 id="基础地图使用"><a href="#基础地图使用" class="headerlink" title="基础地图使用"></a><strong>基础地图使用</strong></h2><blockquote>
<p><strong>1. 掌握使用pyecharts构建基础的全国地图可视化图表</strong></p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/c84b71900e2c45eaae58bc1ade7c7933.jpeg" alt="1"><br><img src="https://img-blog.csdnimg.cn/838999d69f9146cdbd013fb31898d8d1.jpeg" alt="2"></p>
<blockquote>
<p>代码演示</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Python基础综合案例 数据可视化 - 地图可视化</span></span><br><span class="line"><span class="keyword">from</span> pyecharts.charts <span class="keyword">import</span> Map</span><br><span class="line"><span class="keyword">from</span> pyecharts.options <span class="keyword">import</span> VisualMapOpts</span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建地图对象</span></span><br><span class="line"><span class="built_in">map</span> = Map()</span><br><span class="line">data = [</span><br><span class="line">    (<span class="string">&quot;北京&quot;</span>, <span class="number">11</span>),</span><br><span class="line">    (<span class="string">&quot;上海&quot;</span>, <span class="number">2</span>),</span><br><span class="line">    (<span class="string">&quot;广东&quot;</span>, <span class="number">30</span>),</span><br><span class="line">    (<span class="string">&quot;四川&quot;</span>, <span class="number">40</span>),</span><br><span class="line">    (<span class="string">&quot;江苏&quot;</span>, <span class="number">210</span>),</span><br><span class="line">    (<span class="string">&quot;广州&quot;</span>, <span class="number">314</span>),</span><br><span class="line">    (<span class="string">&quot;湖北&quot;</span>, <span class="number">65</span>)</span><br><span class="line">]</span><br><span class="line"><span class="comment"># 添加数据</span></span><br><span class="line"><span class="built_in">map</span>.add(<span class="string">&quot;地图&quot;</span>, data, <span class="string">&quot;china&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置全局选项</span></span><br><span class="line"><span class="built_in">map</span>.set_global_opts(</span><br><span class="line">    <span class="comment"># 视觉映射配置</span></span><br><span class="line">    visualmap_opts=VisualMapOpts(</span><br><span class="line">        <span class="comment"># 允许显示</span></span><br><span class="line">        is_show=<span class="literal">True</span>,</span><br><span class="line">        <span class="comment"># 允许手动校准范围</span></span><br><span class="line">        is_piecewise=<span class="literal">True</span>,</span><br><span class="line">        <span class="comment"># 校准参数配置</span></span><br><span class="line">        pieces=[</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">1</span>, <span class="string">&quot;max&quot;</span>: <span class="number">9</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;1-9&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#CCFFFF&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">10</span>, <span class="string">&quot;max&quot;</span>: <span class="number">99</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;10-99&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#CCFF66&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">100</span>, <span class="string">&quot;max&quot;</span>: <span class="number">500</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;100-500&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#990033&quot;</span>&#125;</span><br><span class="line">        ]</span><br><span class="line">    )</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘图</span></span><br><span class="line"><span class="built_in">map</span>.render() </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="疫情地图-国内疫情地图"><a href="#疫情地图-国内疫情地图" class="headerlink" title="疫情地图-国内疫情地图"></a><strong>疫情地图-国内疫情地图</strong></h2><blockquote>
<p>数据源文件</p>
</blockquote>
<p> <a target="_blank" rel="noopener" href="https://sharewh1.xuexi365.com/share/download/fd913a91368eb72ccefd078213c2e5f4">疫情.txt</a></p>
<p> <img src="https://p.ananas.chaoxing.com/star3/origin/eb272f91270e57c70013902aa4b01dfc.png" alt="1"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/702575d784477cc1164875469b7b5ae5.png" alt="2"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/333246601061b0e6bb892b15254f325a.png" alt="3"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/7f4b12a83890618dfc13f498dc6945ee.png" alt="4"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/4454591ba5ead94de68642f0b3bf02c4.png" alt="5"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/0e4ae64c799404073a344acc8c7bafab.png" alt="6"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/478bab1b2d8f2814647353e03a63f6e7.png" alt="7"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/286b1063b03fb532efee6d6e99d7bdf6.png" alt="8"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/83f2f8f6a7d3f9a3e3171c28a03f1713.png" alt="9"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/5026fa07ba54d3606bd34258dec469f5.png" alt="10"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/718cdbea73b16cee3e34b86b081bbe9d.png" alt="11"><br> <img src="https://p.ananas.chaoxing.com/star3/origin/ca043e3cbf11dbc64c7a21b4e92b9292.png" alt="12"></p>
<blockquote>
<p>视频课程</p>
</blockquote>
<iframe src="//player.bilibili.com/player.html?aid=941747210&bvid=BV1qW4y1a7fU&cid=818138408&page=106" scrolling="no" border="0" height="500" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

<blockquote>
<p>代码演示</p>
</blockquote>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="keyword">from</span> pyecharts.charts <span class="keyword">import</span> Map</span><br><span class="line"><span class="keyword">from</span> pyecharts.options <span class="keyword">import</span> *</span><br><span class="line"><span class="comment"># 读取文件</span></span><br><span class="line"><span class="keyword">import</span> json</span><br><span class="line"></span><br><span class="line">filePath = <span class="string">&quot;/Volumes/E盘/资料/可视化案例数据/地图数据/疫情.txt&quot;</span></span><br><span class="line"></span><br><span class="line">f = <span class="built_in">open</span>(filePath, <span class="string">&#x27;r&#x27;</span>, encoding=<span class="string">&#x27;utf-8&#x27;</span>)</span><br><span class="line">data = f.read()</span><br><span class="line">f.close()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 取到各省的数据</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 将字符串json转换为python字典</span></span><br><span class="line">dict_data = json.loads(data)</span><br><span class="line"><span class="comment"># 从字典中取出省份数据</span></span><br><span class="line">province_data_list = dict_data[<span class="string">&#x27;areaTree&#x27;</span>][<span class="number">0</span>][<span class="string">&#x27;children&#x27;</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 组装每个省份和确诊人数为元组，并各个省份的数据都封入列表中</span></span><br><span class="line">data_list = []</span><br><span class="line"><span class="keyword">for</span> province_data <span class="keyword">in</span> province_data_list:</span><br><span class="line">    province_name = province_data[<span class="string">&quot;name&quot;</span>]  <span class="comment"># 省份名称</span></span><br><span class="line">    province_confirm = province_data[<span class="string">&quot;total&quot;</span>][<span class="string">&quot;confirm&quot;</span>]  <span class="comment"># 确诊人数</span></span><br><span class="line">    data_list.append((province_name, province_confirm))</span><br><span class="line"></span><br><span class="line"><span class="comment"># print(data_list)</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建地图对象</span></span><br><span class="line"><span class="built_in">map</span> = Map()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 添加数据</span></span><br><span class="line"><span class="built_in">map</span>.add(<span class="string">&quot;各省份确诊人数&quot;</span>, data_list, <span class="string">&quot;china&quot;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置全局配置，定制分段的视觉映射</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">map</span>.set_global_opts(</span><br><span class="line">    title_opts=TitleOpts(title=<span class="string">&quot;全国疫情地图&quot;</span>),</span><br><span class="line">    visualmap_opts=VisualMapOpts(</span><br><span class="line">        is_show=<span class="literal">True</span>,</span><br><span class="line">        is_piecewise=<span class="literal">True</span>,</span><br><span class="line">        pieces=[</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>:<span class="number">1</span>,<span class="string">&quot;max&quot;</span>:<span class="number">99</span>,<span class="string">&quot;lable&quot;</span>:<span class="string">&quot;1~99人&quot;</span>,<span class="string">&quot;color&quot;</span>:<span class="string">&quot;#FF1493&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>:<span class="number">100</span>,<span class="string">&quot;max&quot;</span>:<span class="number">999</span>,<span class="string">&quot;lable&quot;</span>:<span class="string">&quot;100~999人&quot;</span>,<span class="string">&quot;color&quot;</span>:<span class="string">&quot;#FFEBCD&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>:<span class="number">1000</span>,<span class="string">&quot;max&quot;</span>:<span class="number">9999</span>,<span class="string">&quot;lable&quot;</span>:<span class="string">&quot;1000~9999人&quot;</span>,<span class="string">&quot;color&quot;</span>:<span class="string">&quot;#40E0D0&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>:<span class="number">10000</span>,<span class="string">&quot;max&quot;</span>:<span class="number">99999</span>,<span class="string">&quot;lable&quot;</span>:<span class="string">&quot;10000~99999人&quot;</span>,<span class="string">&quot;color&quot;</span>:<span class="string">&quot;#5F9EA0&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>:<span class="number">100000</span>,<span class="string">&quot;max&quot;</span>:<span class="number">999999</span>,<span class="string">&quot;lable&quot;</span>:<span class="string">&quot;100000~999999人&quot;</span>,<span class="string">&quot;color&quot;</span>:<span class="string">&quot;#DAA520&quot;</span>&#125;,</span><br><span class="line">        ]</span><br><span class="line">    )</span><br><span class="line">)</span><br><span class="line"><span class="comment"># 绘图</span></span><br><span class="line"><span class="built_in">map</span>.render()</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="疫情地图-省级疫情地图"><a href="#疫情地图-省级疫情地图" class="headerlink" title="疫情地图-省级疫情地图"></a><strong>疫情地图-省级疫情地图</strong></h2><p><img src="https://p.ananas.chaoxing.com/star3/origin/e65c437bf5be90fa4334b6001e13e957.png" alt="1"><br><img src="https://p.ananas.chaoxing.com/star3/origin/95012f29c10cd7026e314805db22e6a2.png" alt="2"><br><img src="https://p.ananas.chaoxing.com/star3/origin/cdcbdac747af2dea5afb0f8feb751888.png" alt="3"><br><img src="https://p.ananas.chaoxing.com/star3/origin/8ad8d024f4d021749ce0cc12f710880f.png" alt="4"><br><img src="https://p.ananas.chaoxing.com/star3/origin/1e08341c2bc7cb98629e78964f3a28d3.png" alt="5"></p>
<blockquote>
<p>视频课程</p>
</blockquote>
<iframe src="//player.bilibili.com/player.html?aid=941747210&bvid=BV1qW4y1a7fU&cid=818138829&page=107" scrolling="no" border="0" height="500"  frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

<blockquote>
<p>代码演示</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 导入json包</span></span><br><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="comment"># 导入 地图包</span></span><br><span class="line"><span class="keyword">from</span> pyecharts.charts <span class="keyword">import</span> Map</span><br><span class="line"><span class="keyword">from</span> pyecharts.options <span class="keyword">import</span> *</span><br><span class="line"></span><br><span class="line"><span class="comment"># 文件路径</span></span><br><span class="line">filePath = <span class="string">&quot;/Volumes/E盘/资料/可视化案例数据/地图数据/疫情.txt&quot;</span></span><br><span class="line"><span class="comment"># 打开文件</span></span><br><span class="line">f = <span class="built_in">open</span>(filePath, <span class="string">&#x27;r&#x27;</span>, encoding=<span class="string">&#x27;utf-8&#x27;</span>)</span><br><span class="line"><span class="comment"># 读取文件内容</span></span><br><span class="line">data = f.read()</span><br><span class="line"><span class="comment"># 关闭文件，避免一直占用内存</span></span><br><span class="line">f.close()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 对数据进行json格式化</span></span><br><span class="line">data = json.loads(data)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 获取各省确诊数据</span></span><br><span class="line">data = data[<span class="string">&#x27;areaTree&#x27;</span>][<span class="number">0</span>][<span class="string">&#x27;children&#x27;</span>]</span><br><span class="line"><span class="comment"># 对数据过滤，提取河南省的各市区确诊数据</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> data:</span><br><span class="line">    <span class="keyword">if</span> i[<span class="string">&quot;name&quot;</span>] == <span class="string">&quot;河南&quot;</span>:</span><br><span class="line">        data = i[<span class="string">&quot;children&quot;</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 创建一个空列表 将河南的各市数据汇总到一个列表里面</span></span><br><span class="line">data_list = [] </span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> city_data <span class="keyword">in</span> data:</span><br><span class="line">    data_list.append(</span><br><span class="line">        (city_data[<span class="string">&quot;name&quot;</span>] + <span class="string">&quot;市&quot;</span>, city_data[<span class="string">&#x27;today&#x27;</span>][<span class="string">&#x27;confirm&#x27;</span>])</span><br><span class="line">    )</span><br><span class="line"><span class="comment"># 手动补全</span></span><br><span class="line">data_list.append((<span class="string">&quot;济源市&quot;</span>, <span class="number">5</span>))</span><br><span class="line"><span class="comment"># 调试输出</span></span><br><span class="line"><span class="built_in">print</span>(data_list)</span><br><span class="line"><span class="comment"># 构建地图</span></span><br><span class="line"><span class="built_in">map</span> = Map()</span><br><span class="line"><span class="comment"># 添加数据</span></span><br><span class="line"><span class="built_in">map</span>.add(<span class="string">&quot;河南省疫情数据&quot;</span>, data_list, <span class="string">&quot;河南&quot;</span>)</span><br><span class="line"><span class="comment"># 地图配置</span></span><br><span class="line"><span class="built_in">map</span>.set_global_opts(</span><br><span class="line">    <span class="comment"># 视觉映射配置</span></span><br><span class="line">    title_opts=TitleOpts(title=<span class="string">&quot;河南省疫情地图&quot;</span>),</span><br><span class="line">    visualmap_opts=VisualMapOpts(</span><br><span class="line">        is_show=<span class="literal">True</span>,       <span class="comment"># 是否显示</span></span><br><span class="line">        is_piecewise=<span class="literal">True</span>,  <span class="comment"># 是否分段</span></span><br><span class="line">        pieces=[</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">1</span>, <span class="string">&quot;max&quot;</span>: <span class="number">9</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;1-9人&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#CCFFFF&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">10</span>, <span class="string">&quot;max&quot;</span>: <span class="number">99</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;10-99人&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#FFFF99&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">100</span>, <span class="string">&quot;max&quot;</span>: <span class="number">499</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;100-499人&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#FF9966&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">500</span>, <span class="string">&quot;max&quot;</span>: <span class="number">999</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;500-999人&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#FF6666&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">1000</span>, <span class="string">&quot;max&quot;</span>: <span class="number">9999</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;1000-9999人&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#CC3333&quot;</span>&#125;,</span><br><span class="line">            &#123;<span class="string">&quot;min&quot;</span>: <span class="number">10000</span>, <span class="string">&quot;label&quot;</span>: <span class="string">&quot;10000人以上&quot;</span>, <span class="string">&quot;color&quot;</span>: <span class="string">&quot;#990033&quot;</span>&#125;,</span><br><span class="line">        ]</span><br><span class="line">    )</span><br><span class="line">)</span><br><span class="line"><span class="comment"># 绘画图标</span></span><br><span class="line"><span class="built_in">map</span>.render(<span class="string">&quot;河南省.html&quot;</span>)</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://grace.666443.xyz">王扣</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://grace.666443.xyz/posts/e46ce5f3.html">http://grace.666443.xyz/posts/e46ce5f3.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://grace.666443.xyz" target="_blank">王扣笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://p.ananas.chaoxing.com/star3/origin/05fcdda2bab7b7f1768a65f0c49762f8.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/18141c11.html"><img class="prev-cover" src="https://p.ananas.chaoxing.com/star3/origin/4f58efcc75f80e499f83b69e6a40f221.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">13.Python综合案例-动态柱状图</div></div></a></div><div class="next-post pull-right"><a href="/posts/29d456a4.html"><img class="next-cover" src="https://p.ananas.chaoxing.com/star3/origin/93817a1b7b5becae58da6acfc5d2c0c4.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">11.Python综合案例-折线可视化</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">王扣</div><div class="author-info__description">常用开发中的笔记记录</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">22</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog 技术笔记</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Python%E5%85%A5%E9%97%A8%E8%AF%BE%E7%A8%8B-Python%E5%9F%BA%E7%A1%80%E7%BB%BC%E5%90%88%E6%A1%88%E4%BE%8B-%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96-%E5%9C%B0%E5%9B%BE%E5%8F%AF%E8%A7%86%E5%8C%96"><span class="toc-number">1.</span> <span class="toc-text">Python入门课程  Python基础综合案例 数据可视化 - 地图可视化</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AB%A0%E8%8A%82%E7%9B%AE%E5%BD%95"><span class="toc-number">1.1.</span> <span class="toc-text">章节目录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E5%9C%B0%E5%9B%BE%E4%BD%BF%E7%94%A8"><span class="toc-number">1.2.</span> <span class="toc-text">基础地图使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%96%AB%E6%83%85%E5%9C%B0%E5%9B%BE-%E5%9B%BD%E5%86%85%E7%96%AB%E6%83%85%E5%9C%B0%E5%9B%BE"><span class="toc-number">1.3.</span> <span class="toc-text">疫情地图-国内疫情地图</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%96%AB%E6%83%85%E5%9C%B0%E5%9B%BE-%E7%9C%81%E7%BA%A7%E7%96%AB%E6%83%85%E5%9C%B0%E5%9B%BE"><span class="toc-number">1.4.</span> <span class="toc-text">疫情地图-省级疫情地图</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/ae1a0acd.html" title="18.Python爬虫-requests模块"><img src="https://p.ananas.chaoxing.com/star3/origin/b230c5f9060b1f422a86e332d8e37926.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="18.Python爬虫-requests模块"/></a><div class="content"><a class="title" href="/posts/ae1a0acd.html" title="18.Python爬虫-requests模块">18.Python爬虫-requests模块</a><time datetime="2022-12-08T12:53:30.000Z" title="发表于 2022-12-08 20:53:30">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/ed7a56b2.html" title="17.Python爬虫-数据解析与提取"><img src="https://p.ananas.chaoxing.com/star3/origin/8f2179d04bfe0e48cc706ae112c97952.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="17.Python爬虫-数据解析与提取"/></a><div class="content"><a class="title" href="/posts/ed7a56b2.html" title="17.Python爬虫-数据解析与提取">17.Python爬虫-数据解析与提取</a><time datetime="2022-12-08T12:52:55.000Z" title="发表于 2022-12-08 20:52:55">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5038ed.html" title="16.Python爬虫-基础"><img src="https://p.ananas.chaoxing.com/star3/origin/2054c03c91d338203c730610ead1b303.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="16.Python爬虫-基础"/></a><div class="content"><a class="title" href="/posts/5038ed.html" title="16.Python爬虫-基础">16.Python爬虫-基础</a><time datetime="2022-12-08T12:52:11.000Z" title="发表于 2022-12-08 20:52:11">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/2b5a0751.html" title="15.Python之Mysql数据库相关"><img src="https://p.ananas.chaoxing.com/star3/origin/2a1821704670b5cf8c2289255e183d62.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="15.Python之Mysql数据库相关"/></a><div class="content"><a class="title" href="/posts/2b5a0751.html" title="15.Python之Mysql数据库相关">15.Python之Mysql数据库相关</a><time datetime="2022-12-08T12:17:02.000Z" title="发表于 2022-12-08 20:17:02">2022-12-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/6ebaa02b.html" title="14.Python面向对象"><img src="https://p.ananas.chaoxing.com/star3/origin/d24d9bfcd4ce3f910d6b5cdc78676d75.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="14.Python面向对象"/></a><div class="content"><a class="title" href="/posts/6ebaa02b.html" title="14.Python面向对象">14.Python面向对象</a><time datetime="2022-12-08T12:10:47.000Z" title="发表于 2022-12-08 20:10:47">2022-12-08</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 王扣</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="false"></script><div class="fb-customerchat" id="fb-customer-chat" attribution="biz_inbox"></div><script>document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')

window.fbAsyncInit = function() {
  FB.init({
    xfbml: true,
    version: 'v15.0'
  });
};

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = 'https://connect.facebook.net/zh_CN/sdk/xfbml.customerchat.js';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

if (false) {
  var chatBtnFn = () => {
    var chatBtn = document.getElementById("chat_btn")
    chatBtn.addEventListener("click", function(){
      FB.CustomerChat.show();
    });
  }
  chatBtnFn()
} else {
  if (false) {
    function chatBtnHide () {
      FB.CustomerChat.hide()
    }
    function chatBtnShow () {
      FB.CustomerChat.show(false)
    }
  }
}</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>